const fs =require('fs');
 var  rds = fs.createReadStream('inout.txt');

 rds.on('data',function(trunk){
    cnt++;
    console.log('第'+cnt +'次读取，共'+byteLength(trunk)+'字节。');
    globalData+=trunk;
    // console.log(trunk);
 });
 rds.on('end',function(trunk){
    console.log("读取文件已完成！");
 });
 rds.on('close',function(){
    console.log("文件已关闭！");
    console.log(globalData);
 });
 rds.on('open',function(trunk){
    console.log("文件已打开");
 });
 rds.on('error',function(err){
    console.log(err);
 });

 console.log("程序执行完毕！");